package com.example.child_protection.controller;

import com.example.child_protection.dto.base.BaseResponseDTO;
import com.example.child_protection.dto.request.SimpleIdRequestDTO;
import com.example.child_protection.dto.request.add.PhysicalExaminationInsertRequestDTO;
import com.example.child_protection.dto.request.add.PhysicalExaminationValues2SaveRequestDTO;
import com.example.child_protection.dto.request.add.PhysicalExaminationValuesSaveRequestDTO;
import com.example.child_protection.dto.request.find.PhysicalExaminationRequestDTO;
import com.example.child_protection.dto.request.update.PhysicalExaminationUpdateRequestDTO;
import com.example.child_protection.dto.response.PhysicalExaminationListResponseDTO;
import com.example.child_protection.dto.response.PhysicalExaminationResponseDTO;
import com.example.child_protection.service.PhysicalExaminationManageService;
import com.example.child_protection.service.PhysicalExaminationQueryService;
import com.example.child_protection.util.ContentType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 体检信息管理控制层
 * @date 2018-11-2
 * @author Biz
 */
@RestController
@RequestMapping("physicalExamination")
@Api(value = "/api-physicalExamination", description = "体检信息管理")
public class PhysicalExaminationController extends BaseController {

    @Autowired
    public PhysicalExaminationManageService physicalExaminationManageService;

    @Autowired
    public PhysicalExaminationQueryService physicalExaminationQueryService;

    @ApiOperation(value ="查询体检信息", httpMethod = "POST",response = BaseResponseDTO.class )
    @RequestMapping(value = "/findId", method = RequestMethod.POST, produces = {ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8})
    public PhysicalExaminationResponseDTO findId(SimpleIdRequestDTO requestDTO,HttpServletRequest request)throws Exception{
        PhysicalExaminationResponseDTO responseDTO = physicalExaminationQueryService.findId(requestDTO);
        return responseDTO;
    }

    @ApiOperation(value ="查询体检信息列表信息", httpMethod = "POST",response = BaseResponseDTO.class )
    @RequestMapping(value = "/findList", method = RequestMethod.POST, produces = {ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8})
    public PhysicalExaminationListResponseDTO findList(PhysicalExaminationRequestDTO requestDTO, HttpServletRequest request)throws Exception{
        PhysicalExaminationListResponseDTO responseDTO = physicalExaminationQueryService.findList(requestDTO);
        return responseDTO;
    }

    @ApiOperation(value ="查询体检总次数", httpMethod = "POST",response = BaseResponseDTO.class )
    @RequestMapping(value = "/count", method = RequestMethod.POST, produces = {ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8})
    public BaseResponseDTO count(PhysicalExaminationRequestDTO requestDTO, HttpServletRequest request)throws Exception{
        BaseResponseDTO responseDTO = physicalExaminationQueryService.count(requestDTO);
        return responseDTO;
    }

    @ApiOperation(value ="保存体检信息", httpMethod = "POST",response = BaseResponseDTO.class )
    @RequestMapping(value = "/insert", method = RequestMethod.POST, produces = {ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8})
    public BaseResponseDTO insert(PhysicalExaminationInsertRequestDTO requestDTO)throws Exception{
        BaseResponseDTO responseDTO = physicalExaminationManageService.insert(requestDTO);
        return responseDTO;
    }

    @ApiOperation(value ="保存体格检查信息", httpMethod = "POST",response = BaseResponseDTO.class )
    @RequestMapping(value = "/saveValues", method = RequestMethod.POST, produces = {ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8})
    public BaseResponseDTO saveValues(PhysicalExaminationValuesSaveRequestDTO requestDTO)throws Exception{
        BaseResponseDTO responseDTO = physicalExaminationManageService.saveValues(requestDTO);
        return responseDTO;
    }

    @ApiOperation(value ="保存专题数据信息", httpMethod = "POST",response = BaseResponseDTO.class )
    @RequestMapping(value = "/saveValues2", method = RequestMethod.POST, produces = {ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8})
    public BaseResponseDTO saveValues2(PhysicalExaminationValues2SaveRequestDTO requestDTO)throws Exception{
        BaseResponseDTO responseDTO = physicalExaminationManageService.saveValues2(requestDTO);
        return responseDTO;
    }

    @ApiOperation(value ="修改体检信息", httpMethod = "POST",response = BaseResponseDTO.class )
    @RequestMapping(value = "/update", method = RequestMethod.POST, produces = {ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8})
    public BaseResponseDTO update(PhysicalExaminationUpdateRequestDTO requestDTO)throws Exception{
        BaseResponseDTO responseDTO = physicalExaminationManageService.update(requestDTO);
        return responseDTO;
    }

    @ApiOperation(value ="删除体检信息", httpMethod = "POST",response = BaseResponseDTO.class )
    @RequestMapping(value = "/delete", method = RequestMethod.POST, produces = {ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8})
    public BaseResponseDTO delete(SimpleIdRequestDTO requestDTO)throws Exception{
        requestDTO.setLastUpdatePersonId(this.getLoginUserId());
        BaseResponseDTO responseDTO = physicalExaminationManageService.delete(requestDTO);
        return responseDTO;
    }

}
